package com.lgq.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.lgq.dao.DepartmentDAO;
import com.lgq.model.Department;
import com.lgq.service.DepartmentService;
import com.lgq.util.Page;
@Component("departmentService")
public class DepartmentServiceImpl implements DepartmentService{
	private DepartmentDAO departmentDAO;
	
	public DepartmentDAO getDepartmentDAO() {
		return departmentDAO;
	}
	@Resource
	public void setDepartmentDAO(DepartmentDAO departmentDAO) {
		this.departmentDAO = departmentDAO;
	}

	@Override
	public Page<Department> getAllDepartment(int currentPage, int numPerPage) {
		// TODO Auto-generated method stub
		System.out.println(this.departmentDAO);
		return this.departmentDAO.getAllDepartment(currentPage, numPerPage);
	}

	@Override
	public Page<Department> findByName(int currentPage, int numPerPage,
			String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Department findById(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean ifNameExists(String name) {
		if(this.departmentDAO.findByName(name)!=null)
		{
			return true;
		}else
		{
			return false;
		}
	}

	@Override
	public boolean updateDepartment(Department department) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean deleteDepartment(Department department) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean addDepartment(Department department) {
		// TODO Auto-generated method stub
		return this.departmentDAO.addDepartment(department);
	}

}
